import { source } from '../services/component';


export default {

  namespace: 'setup',

  state: {

  },

  subscriptions: {
    setup({ dispatch, history }) {
      history.listen(({pathname, query}) => {
        if (pathname.toString() == "/selfinfo/integralrule") {
          dispatch({type: 'integralrule'});
        }
        if (pathname.toString() == "/selfinfo/useGuide") {
          dispatch({type: 'guide'});
        }
        if (pathname.toString() == "/selfinfo/feedback") {
          dispatch({type: 'feedback'});
        }
        if (pathname.toString() == "/selfinfo/aboutUs") {
          dispatch({type: 'aboutUs'});
        }

      })
    }
  },

  effects: {

    //积分规则
    *integralrule({payload}, { call, put, select }) {

      console.log('积分规则');

      yield put({
        type: 'success',
        payload: {

        }
      })
    },

    //使用指南
    *guide({payload}, { call, put, select }) {

      console.log('使用指南');

      yield put({
        type: 'success',
        payload: {

        }
      })
    },

    //反馈
    *feedback({payload}, { call, put, select }) {

      console.log('反馈');

      yield put({
        type: 'success',
        payload: {

        }
      })
    },

    //关于我们
    *aboutUs({payload}, { call, put, select }) {

      console.log('关于我们');

      yield put({
        type: 'success',
        payload: {

        }
      })
    },

  },

  reducers: {
    success(state, action){
      return {...state, ...action.payload};
    }
  }
};
